define(function(require, exports){
	var $ = require("jquery");
	var pubjs = require('pubjs');
	var view = require('@base/view');
	var util = require('util');
	var Edit = require('@mod/fieldEdit').base;
	var dspUtil = require('dspUtil');

	exports.base = Edit.extend({
		init:function(config){
			config = pubjs.conf(config, {
				fields: [
					{text: LANG('类型'), tip: LANG('文件类型'), type: 'dropdown', field: 'log', validate: true,
						config: {
							options: [
								{_id: 'error', Name: LANG('错误日志')}
								,{_id: 'app', Name: LANG('日常日志')}
								,{_id: 'socket', Name: LANG('Socket 请求日志')}
								,{_id: 'front', Name: LANG('前端错误日志')}
							]
							,"def": LANG("请选择")
							,width: 400
						}
					}
					,{
						text: LANG('时间'), type: 'custom', validate: true,
						field: 'date', uri: '@base/common/date.datePickerNew',config:
						{
							showButton: false
						}, getValue: function() {
							return this.getData(true);
						}
					}
					,{text: LANG('行'), tip: LANG('最后N行'), type: 'input', field: 'line'}
					,{text: LANG(''), type: 'button', field: 'go', config: {
						'value': LANG('确定'),
						'class': 'btn btn-primary'
					}}
				],
				isPop: true,
				Title: LANG('日志下载')
			});

			this.$id = null;
			this.Super('init', arguments);
		}
		,dataChange: function(field, v) {
			this.Super('dataChange', arguments);
			if(field === 'go')
			{
				var data = this.getData();
				if(this.validate(data))
				{
					delete data._id;
					delete data.go;
					var url = 'api/admin/blackMagic?type=log' + dspUtil.queryString(data);
					window.open(url);
				}
			}
		}
	});
});